package top.up.demo.loadresources.utils;

import lombok.extern.slf4j.Slf4j;

import java.io.*;

/**
 * 工具类：File
 *
 * @author <a href="mailto:lishuai2015@163.com">Jack.Li</a>
 * @version 1.0
 * @date 2024/01/13
 */
@Slf4j
public class FileUtil {

    /**
     * 根据文件路径读取文件内容 / 打印文件
     *
     * @param fileInPath 文件路径/文件流
     * @throws IOException 异常
     */
    public static void getFileContent(Object fileInPath) throws IOException {
        BufferedReader br = null;
        if (fileInPath == null) {
            return;
        }
        if (fileInPath instanceof String) {
            br = new BufferedReader(new FileReader(new File((String) fileInPath)));
        } else if (fileInPath instanceof InputStream) {
            br = new BufferedReader(new InputStreamReader((InputStream) fileInPath));
        }
        String line;
        while ((line = br.readLine()) != null) {
            log.info(line);
        }
        br.close();
    }

}
